<el-dialog
	v-loading="EditDialogDzz.loading"
	:title="'编辑'+EditDialogDzz.cloudname"
	width="100%"
	style="max-width:600px"
	v-model="EditDialogDzz.dialogVisible">
	<el-form ref="EditDialogDzzref" :model="EditDialogDzz" label-width="110px" label-position="top">
		<el-form-item class="title">
			<template #label>
				图片处理设置
				<el-tooltip 
					effect="light"
					placement="right-start">
					<template  #content>
						<div style="max-width: 300px;">
							<p class="tipTxt" style="margin: 0;">
								1、开启GD库能够支持，{$_G['config']['gdgetcolorextlimit']}，生成缩略图
								<br>
								2、开启imagemagick能够支持，{$_G['config']['imageickallowextlimit']}，文件生成缩略图
							</p>
						</div>
					</template>
					<el-icon style="margin-left: 8px;cursor: pointer;font-size: 16px;color: var(--content-text);"><Warning-Filled /></el-icon>
				</el-tooltip>
				
			</template>
			
			<el-radio-group v-model="EditDialogDzz.imageval" @change="EditDialogDzzImageChange">
				<el-radio border label="0">关闭</el-radio>
				<el-radio border label="gd" :disabled="EditDialogDzz.gdstatus?false:true">GD库</el-radio>
				<el-radio border label="imagick" :disabled="EditDialogDzz.imagickstatus?false:true">imagemagick</el-radio>
			</el-radio-group>
		</el-form-item>
		<el-form-item class="title">
			<template #label>
				媒体处理设置
				<el-tooltip 
					effect="light"
					placement="right-start">
					<template #content>
						<div style="max-width: 300px;">
							<p class="tipTxt" style="margin: 0;">开启后能够支持，视频格式：{$_G['config']['pichomeconvertext']}，生成缩略图，实现在线预览</p>
						</div>
					</template>
					<el-icon style="margin-left: 8px;cursor: pointer;font-size: 16px;color: var(--content-text);"><Warning-Filled /></el-icon>
				</el-tooltip>
				
			</template>
			
			<el-radio-group v-model="EditDialogDzz.mediastatus" @change="EditDialogDzzMediaChange">
				<el-radio border :label="0">关闭</el-radio>
				<el-radio border :disabled="EditDialogDzz.mediastate?false:true" :label="1">ffmpeg</el-radio>
			</el-radio-group>
		</el-form-item>
		<el-form-item label="生成预览视频尺寸" v-if="parseInt(EditDialogDzz.mediastatus)">
			<template #label>
				生成预览视频尺寸：
				<!--{loop $_G['config']['videoquality'] $key $val}-->
				<!--{if $key==$_G['config']['defaultvideoquality']}-->
				$val[name] $val[width]*$val[height] 比特率：$val[bitrate]
				<!--{/if}-->
				<!--{/loop}-->
			</template>
		</el-form-item>
		<el-form-item class="title">
			<template #label>
				office文档处理设置
				<el-tooltip
					effect="light"
					placement="right-start">
					<template #content>
						<div style="max-width: 300px;">
							<p class="tipTxt" style="margin: 0;">开启后能够支持，文档格式：{$_G['config']['onlyofficeviewextlimit']}，生成缩略图，实现在线预览</p>
						</div>
					</template>
					<el-icon style="margin-left: 8px;cursor: pointer;font-size: 16px;color: var(--content-text);"><Warning-Filled /></el-icon>
				</el-tooltip>
				<el-button v-if="EditDialogDzz.docstatus" style="margin-left: 16px;vertical-align: middle;" type="primary" size="mini" @click="EditDialogDzzDocChange('submit')">保存</el-button>
				
			</template>
			
			<el-radio-group v-model="EditDialogDzz.docstatus" @change="EditDialogDzzDocChange">
				<el-radio border :label="0">关闭</el-radio>
				<el-radio border :label="1">OnlyOffice</el-radio>
			</el-radio-group>
		</el-form-item>
		<el-form-item 
			prop="onlyofficeurl"
			label="OnlyOffice Document Server API地址" 
			v-if="EditDialogDzz.docstatus" required
			:rules="{required: true, message: 'OnlyOffice Document Server API地址不能为空', trigger: 'blur'}">
			<el-input v-model="EditDialogDzz.onlyofficeurl" class="maxWidth"></el-input>
			<p class="tipTxt" style="margin: 0;font-size:12px;line-height: 1.5">填写您的onlyoffice Document Server API地址，如:http://192.168.0.2:90/ 根据你的文档服务器填写</p>
		</el-form-item>
		<el-form-item 
			prop="jwtSecret"
			label="JWTSecret" 
			v-if="EditDialogDzz.docstatus"
			>
			<el-input v-model="EditDialogDzz.jwtSecret" class="maxWidth"></el-input>
			<p class="tipTxt" style="margin: 0;font-size:12px;line-height: 1.5">文档服务JWTSecret。7.2版本后，默认开启JWTSecret,这里必须填写。获取方法查看文档服务器欢迎页</p>
		</el-form-item>
		<el-form-item 
			prop="onlyofficedocurl"
			label="文件服务器地址" 
			v-if="EditDialogDzz.docstatus" required>
			<el-input v-model="EditDialogDzz.onlyofficedocurl" class="maxWidth"></el-input>
			<p class="tipTxt" style="margin: 0;font-size:12px;line-height: 1.5">文件服务器地址，如:http://oaooa.com/,根据你的pichome服务器地址填写,留空使用当前地址。<br>tips:设置内网地址可以提高文件传输速度</p>
		</el-form-item>
		<el-form-item 
			prop="exts"
			label="缩略图后缀列表" 
			v-if="EditDialogDzz.docstatus"
			>
			<el-input v-model="EditDialogDzz.exts" class="maxWidth"></el-input>
			<p class="tipTxt" style="margin: 0;font-size:12px;line-height: 1.5">支持生成缩略图的后缀列表，用小写字母。多个用英文逗号隔开，如：pdf,doc,docx,ppt,pptx,xls,xlsx</p>
		</el-form-item>
	</el-form>
</el-dialog>
<script type="text/javascript">
	var EditDialogDzzMixin = {
		data(){
			return {
				EditDialogDzz:{
					loading:false,
					dialogVisible:false,
					cloudname:'',
					id:0,
					
					imagestatus:0,
					imageval:'0',
					gdstatus:0,
					imagickstatus:0,
					
					mediastatus:0,
					mediastate:0,
					
					docstatus:0,
					onlyofficeurl:'http://127.0.0.1:90/',
					onlyofficedocurl:'',
					jwtSecret:'',
					exts:'',
					videoquality:parseInt($_G['config']['videoquality']) || 1
					
				}
			}
		},
		created() {
		},
		methods:{
			async EditDialogDzzDocChange(val){
				var self = this;
				if(val == 0){
					var res = await axios.post(MOD_URL+'&op=storagesetting&do=docsetting',{
						id:self.EditDialogDzz.id,
						docstatus:0,
					});
					if(res == 'intercept'){
						return false;
					}
					var json = res.data;
					if(json.success){
						self.$message({
							type:'success',
							message:'设置成功'
						});
						var tab = self.tableData.find(function(item){
							return parseInt(item.id) == parseInt(self.EditDialogDzz.id);
						});
						tab.docstatus = 0;
					}else{
						self.$message.error('设置失败');
					}	
				}
				if(val == 'submit'){
					self.$refs.EditDialogDzzref.validate(async function(valid){
						if(valid){
							var res = await axios.post(MOD_URL+'&op=storagesetting&do=docsetting',{
								id:self.EditDialogDzz.id,
								docstatus:1,
								onlyofficeurl:self.EditDialogDzz.onlyofficeurl,
								fileurl:self.EditDialogDzz.onlyofficedocurl,
								secret:self.EditDialogDzz.jwtSecret,
								exts:self.EditDialogDzz.exts,
							});
							if(res == 'intercept'){
								return false;
							}
							var json = res.data;
							if(json.success){
								self.$message({
									type:'success',
									message:'设置成功'
								});
								var tab = self.tableData.find(function(item){
									return parseInt(item.id) == parseInt(self.EditDialogDzz.id);
								});
								tab.docstatus = 1;
							}else{
								self.$message.error(json.msg);
							}	
						}
					});
				}
			},
			async EditDialogDzzImageChange(val){
				var self = this;
				if(!self.EditDialogDzz.id){
					self.$message.error('参数错误，请刷新后重试');
					return false;
				}
				var res = await axios.post(MOD_URL+'&op=storagesetting&do=imagesetting',{
					id:self.EditDialogDzz.id,
					imagestatus:parseInt(val)==0?0:1,
					imagelib:val,
				});
				if(res == 'intercept'){
					return false;
				}
				var json = res.data;
				if(json.success){
					self.$message({
						type:'success',
						message:'设置成功'
					});
					var tab = self.tableData.find(function(item){
						return parseInt(item.id) == parseInt(self.EditDialogDzz.id);
					});
					tab.imagestatus = parseInt(val)==0?0:1;
				}else{
					self.$message.error('设置失败');
				}	
			},
			async EditDialogDzzMediaChange(val){
				var self = this;
				if(!self.EditDialogDzz.id){
					self.$message.error('参数错误，请刷新后重试');
					return false;
				}
				var res = await axios.post(MOD_URL+'&op=storagesetting&do=videosetting',{
					id:self.EditDialogDzz.id,
					mediastatus:val,
					videoquality:self.EditDialogDzz.videoqualite,
				});
				if(res == 'intercept'){
					return false;
				}
				var json = res.data;
				if(json.success){
					self.$message({
						type:'success',
						message:'设置成功'
					});
					var tab = self.tableData.find(function(item){
						return parseInt(item.id) == parseInt(self.EditDialogDzz.id);
					});
					tab.mediastatus = val;
				}else{
					self.$message.error('设置失败');
				}	
			},
			async EditDialogDzzGetData(){
				var self = this;
				if(!self.EditDialogDzz.id){
					self.$message.error('参数错误，请刷新后重试');
					return false;
				}
				this.EditDialogDzz.loading = true;
				this.EditDialogDzz.dialogVisible = true;
				
				var res = await axios.post(MOD_URL+'&op=storagesetting&do=getsettingdata',{
					id:self.EditDialogDzz.id,
				});
				if(res == 'intercept'){
					return false;
				}
				var json = res.data;
				self.EditDialogDzz.cloudname = json.cloudname;
				self.EditDialogDzz.imagestatus = parseInt(json.imagestatus);
				self.EditDialogDzz.gdstatus = parseInt(json.gdstatus);
				self.EditDialogDzz.imagickstatus = parseInt(json.imagickstatus);
				self.EditDialogDzz.imageval = (json.imagelib);
				
				if(!self.EditDialogDzz.imagestatus){
					self.EditDialogDzz.imageval = '0';
				}
				
				self.EditDialogDzz.mediastatus = parseInt(json.mediastatus);
				self.EditDialogDzz.mediastate = parseInt(json.mediastate);
				if(!self.EditDialogDzz.mediastate){
					self.EditDialogDzz.mediastatus = 0;
				}
				
				
				self.EditDialogDzz.docstatus = parseInt(json.docstatus);
				self.EditDialogDzz.loading = false;
				
				self.EditDialogDzz.onlyofficeurl=json.officedata.DocumentUrl;
				self.EditDialogDzz.onlyofficedocurl=json.officedata.FileUrl;
				self.EditDialogDzz.exts=json.officedata.exts;
				self.EditDialogDzz.jwtSecret=json.officedata.secret;
				
				
			}
		}
	};
</script>